{include file="public/head"/} 
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">后台管理</a>
        <a href="">人员信息管理中心</a>
        <a><cite>人员管理</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
          <form class="layui-form layui-col-md12 x-so"  method="get" action="#">
            <div class="layui-input-inline">
              <select name="community" lay-filter="community" id="community">
                <option value="">所属小区</option>
                  {foreach $communitylist as $com}
                  <option value="{$com.id}" {if isset($community)}{if $community == $com.id}selected{/if}{/if}>{$com.name}</option>
                  {/foreach}
              </select>
            </div>
            <div class="layui-input-inline">
              <select name="group" id="group" lay-filter="group">
                <option value="">组团</option>
                {if isset($groups)}
                  {foreach $groups as $gro}
                    <option value="{$gro}" {if isset($group)}{if $gro == $group}selected{/if}{/if}>{$gro}</option>
                  {/foreach}
                {/if}
              </select>
            </div>
            <div class="layui-input-inline">
              <select name="building" id="building" lay-filter="building">
                <option value="">所属楼栋</option>
                {if isset($buildings)}
                  {foreach $buildings as $build}
                    <option value="{$build}" {if isset($building)}{if $build == $building}selected{/if}{/if}>{$build}幢</option>
                  {/foreach}
                {/if}
              </select>
            </div>
            <div class="layui-input-inline">
              <select name="unit" id="unit"  lay-filter="unit">
                <option value="">所属单元</option>
                {if isset($units)}
                  {foreach $units as $uni}
                    <option value="{$uni}" {if isset($unit)}{if $uni == $unit}selected{/if}{/if}>{$uni}单元</option>
                  {/foreach}
                {/if}
              </select>
            </div>
            <div class="layui-input-inline">
              <select name="room" id="room" lay-filter="room">
                <option value="">所属房号</option>
                {if isset($rooms)}
                  {foreach $rooms as $roo}
                    <option value="{$roo}" {if isset($room)}{if $roo == $room}selected{/if}{/if}>{$roo}室</option>
                  {/foreach}
                {/if}
              </select>
            </div>
            <input class="layui-input" placeholder="姓名" name="name" value="{if isset($name)}{$name}{/if}">
            <input class="layui-input" placeholder="手机号" name="phone" value="{if isset($phone)}{$phone}{/if}">
            <input class="layui-input" placeholder="锁号" name="serial" value="{if isset($serial)}{$serial}{/if}">
            <div class="layui-input-inline">
              <select name="relation" id="relation" lay-filter="relation">
                <option value="">关系</option>
                <option value="1" {if isset($relation)}{if $relation == '1'}selected{/if}{/if}>业主</option>
                <option value="2" {if isset($relation)}{if $relation == '2'}selected{/if}{/if}>家人</option>
                <option value="3" {if isset($relation)}{if $relation == '3'}selected{/if}{/if}>租客</option>
                <option value="4" {if isset($relation)}{if $relation == '4'}selected{/if}{/if}>访客</option>
              </select>
            </div>
            <div class="layui-input-inline">
              <select name="status" id="status" lay-filter="status">
                <option value="">认证状态</option>
                <option value="1" {if isset($status)}{if $status == '1'}selected{/if}{/if}>已认证</option>
                <option value="2" {if isset($status)}{if $status == '2'}selected{/if}{/if}>未认证</option>
              </select>
            </div>
            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
          </form>
      </div>
      <xblock>
        <!-- <button class="layui-btn" onclick="x_admin_show('添加物业','{:url('admin/Property/propertyAdd')}',780,600)"><i class="layui-icon"></i>添加物业</button> -->
        <span class="x-right" style="line-height:40px">共有数据：{$number} 条</span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
            <!-- <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th> -->
            <th>所属小区</th>
            <th>房号</th>
            <th>关系</th>
            <th>姓名</th>
            <th>手机号</th>
            <th>支付宝账号</th>
            <th>验证锁号</th>
            <th>状态</th>
           
            <th>操作</th> 
          </tr>
        </thead>
        <tbody>
          {foreach $list as $lis}
          <tr>
            <!-- <td>
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
            </td> -->
            <td>{$lis.community_id}</td>
            <td>{$lis.room_id}</td>
            <td>
              {if $lis.relation == 1}
              业主
              {elseif $lis.relation == 2}
              家人
              {elseif $lis.relation == 3}
              租客
              {elseif $lis.relation == 4}
              访客
              {/if}
            </td>
            <td>{$lis.name}</td>
            <td>{$lis.phone}</td>
            <td>{$lis.user_id}</td>
            <td></td>
            <td>
              {if $lis.status == 1}
              已验证
              {elseif $lis.status == 2}
              未验证
              {/if}
            </td>
          
             <td class="td-manage">
             
                <a title="删除" onclick="propertyDel('{$lis.id}', '{$lis.id}')" href="javascript:;" id="{$lis.id}">
                  <i class="layui-icon">&#xe640;</i>
                </a>
            </td> 
          </tr>
          {/foreach}
        </tbody>
      </table>
      <div class="page">
        <div>
            {$personnellist->render()}
        </div>
      </div>

    </div>
    <script>

      //删除
      function propertyDel(id, doc){
        if(confirm('确定要删除吗?')) 
        { 
          var url = "{:url('propertyDel')}?id=" + id
          // console.log(url)
          $('#' + doc).attr('href', url)
        } 
          return false; 
      } 
    </script>
    <script>
        layui.use(['form'], function() {
            var form = layui.form
            form.on('select(community)', function(f){
                var url = "{:url('admin/Apiuser/fetchdata')}"
                $.post(url, {community: f.value, type: 1}, function(data) {
                    $('#group').html("")
                    var option = "<option value=''>所有组团</option>"
                    $('#group').append(option)
                    for (var i = 0; i < data.length; i++) {
                    option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                    $('#group').append(option)
                    }
                    
                    form.render('select')
                })
                
                $('#community').data('community', f.value)
            })

            form.on('select(group)', function(f){
                var data_community = $('#community').data('community')
                var get_community = "<?php if (isset($community)) { echo $community;}?>"
                var community = typeof data_community === 'undefined' ? get_community : data_community
                var url = "{:url('admin/Apiuser/fetchdata')}"
                $.post(url, {community: community, group: f.value, type: 2}, function(data) {
                    $('#building').html("")
                    var option = "<option value=''>所有楼栋</option>"
                    $('#building').append(option)
                    for (var i = 0; i < data.length; i++) {
                        option = "<option value='" + data[i] + "'>" + data[i] + "幢</option>"
                        $('#building').append(option)
                    }
                    $('#group').data('group', f.value)
                    form.render('select')
                })
            })
    
            form.on('select(building)', function(f){
                var data_community = $('#community').data('community')
                var get_community = "<?php if (isset($community)) { echo $community;}?>"
                var community = typeof data_community === 'undefined' ? get_community : data_community

                var data_group = $('#group').data('group')
                var get_group = "<?php if (isset($group)) { echo $group;}?>"
                var group = typeof data_group === 'undefined' ? get_group : data_group

                var url = "{:url('admin/Apiuser/fetchdata')}"
                $.post(url, {building: f.value, community: community, group: group, type: 3}, function(data) {
                $('#unit').html("")
                var option = "<option value=''>所有单元</option>"
                $('#unit').append(option)
                for (var i = 0; i < data.length; i++) {
                    option = "<option value='" + data[i] + "'>" + data[i] + "单元</option>"
                    $('#unit').append(option)
                }
                $('#building').data('building', f.value)
                form.render('select')
                })
            })
    
            form.on('select(unit)', function(f){
                var data_community = $('#community').data('community')
                var get_community = "<?php if (isset($community)) { echo $community;}?>"
                var community = typeof data_community === 'undefined' ? get_community : data_community

                var data_group = $('#group').data('group')
                var get_group = "<?php if (isset($group)) { echo $group;}?>"
                var group = typeof data_group === 'undefined' ? get_group : data_group

                var data_building = $('#building').data('building')
                var get_building = "<?php if (isset($building)) { echo $building;}?>"
                var building = typeof data_building === 'undefined' ? get_building : data_building
        
                var url = "{:url('admin/Apiuser/fetchdata')}"
                $.post(url, {unit: f.value, community: community, group: group, building: building, type: 4}, function(data) {
                $('#room').html("")
                var option = "<option value=''>所有房间</option>"
                $('#room').append(option)
                for (var i = 0; i < data.length; i++) {
                    option = "<option value='" + data[i] + "'>" + data[i] + "室</option>"
                    $('#room').append(option)
                }
                $('#unit').data('unit', f.value)
                form.render('select')
                })
            })
    
        })
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
  </body>

</html>